package grg.learn.compose.wanandroid

import android.os.Bundle
import android.util.Log
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.viewModels
import androidx.compose.animation.shrinkOut
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.lifecycle.lifecycleScope
import com.google.accompanist.swiperefresh.rememberSwipeRefreshState
import com.google.gson.Gson
import grg.learn.compose.wanandroid.config.AppViewModelCreateFactory
import grg.learn.compose.wanandroid.data.model.IndexArticle
import grg.learn.compose.wanandroid.data.model.IndexArticlePage
import grg.learn.compose.wanandroid.ui.foundations.GText
import grg.learn.compose.wanandroid.ui.page.index.Home
import grg.learn.compose.wanandroid.ui.page.index.HomePageStatus
import grg.learn.compose.wanandroid.ui.theme.GApp
import grg.learn.compose.wanandroid.viewmodels.MainViewModel
import kotlinx.coroutines.Job
import kotlinx.coroutines.async
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.launch
import kotlin.random.Random

class MainActivity : ComponentActivity() {

    private val mainVM: MainViewModel by viewModels { AppViewModelCreateFactory }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        setContent {

            GApp()

//            val homePageStatus by remember {
//                mutableStateOf(
//                    HomePageStatus(vm = mainVM)
//                )
//            }
//
//            var index by remember {
//                mutableStateOf(0)
//            }
//
//            ComposewanandroidTheme {
//
//
//                Column {
//                    Row {
//                        GText(text = "主界面",
//                            Modifier
//                                .padding(5.dp)
//                                .clickable {
//                                    index = 0
//                                })
//                        GText(text = "界面2",
//                            Modifier
//                                .padding(5.dp)
//                                .clickable {
//                                    index = 1
//                                })
//                    }
//                    Box {
//                        if (index == 0) {
//                            Home(homePageStatus)
//                        } else if (index == 2) {
//
//                        }
//
//                    }
//                }
//
//            }

        }


    }
}